package com.eims.sls_app.utils;

import com.eims.sls_app.utils.SnsPopupWindow.OnItemClickListener;

import bls.juejin.cn.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;
import android.widget.TextView;

public class PopupWindowUtil_sns implements OnClickListener {
	private final static String TAG = "PopupWindowUtil_sns";
	private PopupWindow popWindow;// 弹出窗口
	private Activity activity;// 依赖的activity
	private View relyView;// 依赖的控件
	private int id;
	private String contexts;
	private Context context;
	private LayoutInflater inflact;
	private TextView digBtn;
	private TextView commentBtn;
	// 实例化一个矩形
		private Rect mRect = new Rect();
		// 坐标的位置（x、y）
		private final int[] mLocation = new int[2];
		// 弹窗子类项选中时的监听
		private OnItemClickListener mItemClickListener;
	
	public PopupWindowUtil_sns(Activity activity,
			View relyView, int id) {
		super();
		this.activity = activity;
		this.relyView = relyView;
		this.id = id;
	}
	public PopupWindowUtil_sns(Activity activity, View relyView, int id,
			String contexts) {
		super();
		this.activity = activity;
		this.relyView = relyView;
		this.id = id;
		this.contexts = contexts;
	}
	
	/** 创建popWindow */
	private void createPopWindow(){
		inflact = LayoutInflater.from(activity);
		View view = inflact.inflate(R.layout.social_sns_popupwindow, null);
		digBtn = (TextView) view.findViewById(R.id.upBtn);
		commentBtn = (TextView) view.findViewById(R.id.commentBtn);
		digBtn.setOnClickListener(this);
		commentBtn.setOnClickListener(this);
		popWindow = new PopupWindow(view, AppTools.dip2px(context, 100),
				AppTools.dip2px(context, 30), true);
		//this.setContentView(view);
		popWindow.setWidth(AppTools.dip2px(context, 100));
		popWindow.setHeight(AppTools.dip2px(context, 30));
		popWindow.setFocusable(true);
		popWindow.setOutsideTouchable(true);
		popWindow.update();
		// 实例化一个ColorDrawable颜色为半透明
		ColorDrawable dw = new ColorDrawable(0000000000);
		// 点back键和其他地方使其消失,设置了这个才能触发OnDismisslistener ，设置其他控件变化等操作
		popWindow.setBackgroundDrawable(dw);
		popWindow.setAnimationStyle(R.style.social_pop_anim);
		
	}
	@Override
	public void onClick(View v) {
		popWindow.dismiss();
		switch (v.getId()) {
		case R.id.upBtn:
			//mItemClickListener.onItemClick(mActionItems.get(0), 0);
			break;
		case R.id.commentBtn:
			//mItemClickListener.onItemClick(mActionItems.get(1), 1);
			break;
		default:
			break;
		}
		
	}
	
	
	
	
}
